
package com.woniuxy.handler;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.woniuxy.pojo.Room;
import com.woniuxy.service.RoomService;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.woniuxy.pojo.Room;
import com.woniuxy.pojo.RoomType;
import com.woniuxy.pojo.Room_yyh;
import com.woniuxy.service.RoomService;

import lombok.Data;

/**
 * @author Fz
 * @date 2019年8月6日 上午11:56:30
 * @param 
 * @return
 */

@RestController
@RequestMapping("/room")
@ResponseBody
public class RoomHandler {
	@Resource
	private RoomService roomService;
	
	@RequestMapping("/showAll")
	public List<Room_yyh> showAll(){
		return roomService.getAll();
	}
	
	@RequestMapping("/updateR")
	public String updateR(Room room){
		if(roomService.updateR(room)>0){
			return "修改成功";
		}else{
			return "修改失败";
		}
	}
	
	@RequestMapping("/delR")
	public String delRoom(int rid){
		if(roomService.deleteR(rid) > 0){
			return "删除成功";
		}else{
			return "删除失败";
		}
	}
	
	@RequestMapping("/addR")
	public String addRoom(Room room){
		if(roomService.insertR(room)>0){
			return "添加成功";
		}else{
			return "添加失败";
		}
	}
	
	
	@RequestMapping("/findByType")
	public List<Room> findByType(String rtname){
		return roomService.findByType(rtname);
	}
	
	@RequestMapping("/findByState")
	public List<Room> findByState(String rstate){
		return roomService.findByState(rstate);
	}
	
	@RequestMapping("/showType")
	public List<RoomType> showType(){
		return roomService.showType();
	}
	
	@RequestMapping("/addT")
	public String addRoomType(RoomType roomType){
		if(roomService.insertR(roomType)>0){
			return "添加成功";
		}else{
			return "添加失败";
		}
	}
	
	@RequestMapping("/select")
	public List<Room_yyh> selectR(String message){
		return roomService.selectR(message);
	}
}
